package com.cs797.project;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.util.Log;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class Marker extends Overlay {

    private static final String TAG = "Marker";
    
    Context context;
    GeoPoint location = null;
    int drawable;

    public Marker(GeoPoint location, Context ctx, int drawableId)
    {
        super();
        this.location = location;
        context = ctx;
        drawable = drawableId;
    }

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow)
    {
        super.draw(canvas, mapView, shadow);
        //Log.d(TAG, "adding marker...");
        Point screenPoint = new Point();
        mapView.getProjection().toPixels(this.location, screenPoint);
        canvas.drawBitmap(BitmapFactory.decodeResource(context.getResources(), drawable),
            screenPoint.x - 32, screenPoint.y - 32, null);  // -8 as image is 16px high
    }
    
}
